﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace Book
{
    public class BookAppServices :CrudAppService<Book,BookDTO,Guid, BookListDTO, CreateUpdateBookDto>,IBookAppService 
    {
        private readonly IRepository<Book, Guid> _bookrepository;
        private readonly IRepository<tbCommodityType, Guid> _typerepository;

        public BookAppServices(IRepository<Book, Guid> bookrepository,IRepository<tbCommodityType,Guid> typerepository) : base(bookrepository)
        {
            _bookrepository = bookrepository;
            _typerepository = typerepository;
        }
     


        [Obsolete]
        protected override IQueryable<Book> CreateFilteredQuery(BookListDTO input)
        {

            ////显示未入回收站的内容
            if (input.ProductDisplay==1)
            {
                return base.CreateFilteredQuery(input).Where(s => s.ProductDisplay.Equals(input.ProductDisplay));
            }
            ////显示加入回收站的内容
            if (input.ProductDisplay == 0)
            {
                return base.CreateFilteredQuery(input).Where(s => s.ProductDisplay.Equals(input.ProductDisplay));
            }

            return base.CreateFilteredQuery(input).WhereIf(!string.IsNullOrEmpty(input.Name),
                b => b.ProductName.Contains(input.Name)).Where(s => s.ProductDisplay.Equals(input.ProductDisplay));
        }
    }
}
